
var httpRequest;

function create()
{
  var grin = document.getElementById("grin").value;
  var filename = document.getElementById("filename").value;
  httpRequest = callServerSideFunction("create.php?filename="+ filename +"&grin=" + grin,"update()",true);
  var status = document.getElementById("status");
  status.innerHTML = "Creating flash ...";
}

function update()
{
  var status = document.getElementById("status");
  var filename = httpRequest.responseText;
  if (filename == "ERROR")
  {
    status.innerHTML = "Unable to create flash.";
    removeFlash();
  }
  else
  {
    status.innerHTML = 'Done.  [<a href="' + filename + '">'+ filename + '</a>]';
    updateFlash(filename);
  }
  
}

function updateFlash(filename)
{
  var flashHtml = '<object class="grincode">';
  flashHtml += '<param name="movie" value="'+ filename +'">';
  flashHtml += '<embed src="'+ filename +'" class="grincode"></embed>';
  flashHtml += '</object>';
  document.getElementById('flashArea').innerHTML = flashHtml;
  document.getElementById("filename").value = filename;
}

function removeFlash()
{
  document.getElementById('flashArea').innerHTML = "";
}
